	<h3 id="comments" class="cat_heading">{{entry.comments.count}} to "{{entry.title}}"</h3>

	<ol class="commentlist" id="commentlist" >

	{% for comment in entry.comments %}

		<li class="{%cycle alt1,alt %}" id="comment-{{comment.key.id}}">
		<div class="gravatar"><img height="50" width="50" class="avatar avatar-50" src="{{comment.gravatar_url}}" alt=""/></div>
		<div class="comment-entry">
			<cite>{%if comment.weburl %}
			<a href="{{comment.weburl}}" target="_blank" rel="external nofollow" >{{comment.author}}</a>
			{% else %}{{comment.author}}{%endif%}
			</cite>
			<div class="comment-number"><a href="#commentarea" onclick="return backcomment('{{comment.author}}');">回复</a> # {{comment.key.id}}</div>
			<small><a href="#comment-{{comment.key.id}}" title="">{{comment.date|datetz:"Y-m-d"}} at {{comment.date|datetz:"H:i"}}</a></small>
			<p>{{comment.content}}</p>
		</div>
		</li>
{% endfor %}
	</ol>


<div class="clearbar">&nbsp;</div>
<h3 id="respond">Leave a Reply</h3>
<form action="/post_comment" method="post" id="commentform">
<div class="alignleft">
<p>
<label for="author"><small>Name </small></label><br />
<input type="text" name="author" id="author"  size="25" tabindex="1" />
</p>

<p>
<label for="email"><small>Email </small></label><br />
<input type="text" name="email" id="email"  size="25" tabindex="2" />
</p>

<p>
<label for="url"><small>Website</small></label><br />
<input type="text" name="url" id="url"  size="25" tabindex="3" />
</p>
<p id="checkarea">请输入计算结果：<span style="color:#D50000" id="disp_check">{{checknum1}}+{{checknum2}}</span>
<input type="hidden" name="checknum" id="checknum" value="{{checknum1}}+{{checknum2}}" />
<input type="text" name="checkret" id="checkret" value="" size="5" tabindex="4" />
</p>
<script type="text/javascript">/*<![CDATA[*/function grin(tag) { 
        if (typeof tinyMCE != 'undefined') { 
            grin_tinymcecomments(tag); 
        } else { 
            grin_plain(tag); 
        } 
    } 
    function grin_tinymcecomments(tag) { 
        tinyMCE.execCommand('mceInsertContent', false, ' ' + tag + ' '); 
    } 
    function grin_plain(tag) { 
        var myField; 
        var myCommentTextarea = "comment"; 
        tag = ' ' + tag + ' '; 
        if (document.getElementById(myCommentTextarea) && document.getElementById(myCommentTextarea).type == 'textarea') { 
            myField = document.getElementById(myCommentTextarea); 
        } else { 
            return false; 
        } 
        if (document.selection) { 
            myField.focus(); 
            sel = document.selection.createRange(); 
            sel.text = tag; 
            myField.focus(); 
        } 
        else if (myField.selectionStart || myField.selectionStart == '0') { 
            var startPos = myField.selectionStart; 
            var endPos = myField.selectionEnd; 
            var cursorPos = endPos; 
            myField.value = myField.value.substring(0, startPos) 
                          + tag 
                          + myField.value.substring(endPos, myField.value.length); 
            cursorPos += tag.length; 
            myField.focus(); 
            myField.selectionStart = cursorPos; 
            myField.selectionEnd = cursorPos; 
        } 
        else { 
            myField.value += tag; 
            myField.focus(); 
        } 
    } 
    function moreSmilies() { 
        document.getElementById('wp-smiley-more').style.display = 'inline'; 
        document.getElementById('wp-smiley-toggle').innerHTML = '<a href="javascript:lessSmilies()">&laquo;less</a></span>'; 
    } 
    function lessSmilies() { 
        document.getElementById('wp-smiley-more').style.display = 'none'; 
        document.getElementById('wp-smiley-toggle').innerHTML = '<a href="javascript:moreSmilies()">more&raquo;</a>'; 
    }/*]]>*/</script> 

<p> 
<img src='http://pic1.taogogo.info/static/images/icon/icon_smile.gif' alt=':)' onclick='grin("^~smile~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_lol.gif' alt='lol' onclick='grin("^~lol~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_cool.gif' alt='8)' onclick='grin("^~cool~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_mrgreen.gif' alt='mrgreen' onclick='grin("^~mrgreen~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_evil.gif' alt='evil' onclick='grin("^~evil~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_arrow.gif' alt='arrow' onclick='grin("^~arrow~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_sad.gif' alt=':(' onclick='grin("^~sad~^")' class='wp-smiley-select' /> <span id="wp-smiley-more" style="display:none"><img src='http://pic1.taogogo.info/static/images/icon/icon_wink.gif' alt='wink' onclick='grin("^~wink~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_neutral.gif' alt=':-|' onclick='grin("^~neutral~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_mad.gif' alt=':-x' onclick='grin("^~mad~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_eek.gif' alt='8-O' onclick='grin("^~eek~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_rolleyes.gif' alt='roll' onclick='grin("^~rolleyes~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_razz.gif' alt=':-P' onclick='grin("^~razz~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_redface.gif' alt='oops' onclick='grin("^~redface~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_idea.gif' alt='idea' onclick='grin("^~idea~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_biggrin.gif' alt=':-D' onclick='grin("^~biggrin~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_cry.gif' alt='cry' onclick='grin("^~cry~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_question.gif' alt='?' onclick='grin("^~question~^")' class='wp-smiley-select' /> <img src='http://pic1.taogogo.info/static/images/icon/icon_exclaim.gif' alt='!' onclick='grin("^~exclaim~^")' class='wp-smiley-select' /> </span> <span id="wp-smiley-toggle"><a href="javascript:moreSmilies()">more&nbsp;&raquo;</a></span> 
</p>


<p><textarea name="comment" id="comment"   rows="10" tabindex="5" cols="400" onKeyDown=" return quickcomments(event)" ></textarea></p>
<div id="s_msg" style="display:none;color:red">正在提交留言...</div>

<p>
<input name="submit" type="submit" id="submit" tabindex="6" value="Submit Comment(Ctrl+Enter)" />
<input type="hidden" name="key" value="{{entry.key}}" />
<input type="hidden" name="useajax" value="1" />
</p>
</div>
</form>
<script  type="text/javascript" >
       loadjs=false;

       commentuser=$.cookie('comment_user');
       if (commentuser)
       {
         [user,email,url]=commentuser.split('#@#');
         $('#author').val(user);
         $('#email').val(email);
         $('#url').val(url);
         $('#checkarea').hide();
       }
       else
       {
       	num1=Math.round(Math.random()*10);
       	num2=Math.round(Math.random()*10);
       	$('#checkarea #checknum').val(num1+'+'+num2);
       	$('#checkarea #disp_check').text(num1+'+'+num2+'=');
       	$('#checkarea').show();
       }

       function showinfo(msg)
       {
       	  alert(msg);
       }
	   //回复自动输入姓名函数
	   function backcomment(msg){
	   backdb=document.getElementById('comment'); 
	   backdb.value="@"+msg;
	   return false;
	   }
	   //ctrl+回车提交函数
	   function quickcomments(event){ 
		if((event.ctrlKey && event.keyCode == 13)||(event.altKey && event.keyCode == 83)) 
		{
		document.getElementById('submit').click();
		return false;
		}
		
		} 
       function add_comment(msg)
       {
       	  comment=$(msg)
       	  if (!loadjs)
       	  {
       	  	$("#commentlist").append(comment).show();
       	  	$.getScript("http://www.taogogo.info/static/js/jquery.color.js", function(){
       	  		 comment.animate( { backgroundColor: '#fbc7c7' }, "slow")
       						.animate( { backgroundColor: 'white' }, "slow")
							loadjs=true;
						});
       	  }else
       	  {
       	  	$("#commentlist").append(comment);
       	  	  comment.animate( { backgroundColor: '#fbc7c7' }, "slow")
       						.animate( { backgroundColor: 'white' }, "slow")

       	  }
       }

              $('#commentform').ajaxForm({
              	type:'post',
              	dataType:  'json',
              	beforeSubmit:function(formData,jqForm,options){
              		   var form = jqForm[0];
              		   if (form.author)
              		   {

	              			 if (!form.author.value)
		              		 {
		              		  showinfo('请输入你的名字!');
		              		  form.author.focus();
		              		  return false;
		              		 }
		              		 if (!form.email.value)
		              		 {
		              		 	showinfo('请输入邮件地址');
		              		 	form.email.focus();
		              		 	return false;
		              		 }
							 else
							 {
							 	 var search_str = /^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/;
								 var email_val = $("#email").val();
								 if(!search_str.test(email_val)){
								 	alert('请输入正确的邮件地址！');
									form.email.focus();
		              		 		return false;
								  }

							 }
           		       }
           		        if ($('#checkarea').css('display')!='none')
								       {
							             if(eval(form.checknum.value)!=form.checkret.value)
							             {
							               alert('计算错误，请仔细算下！');
							               form.checkret.value='';
							               form.checkret.focus();
							               return false;
							             }

							           }

                  		 if (!form.comment.value)
                  		 {
                  		 	showinfo('请输入留言内容');
                  		 	form.comment.focus();
                  		 	return false;
                  		 }

                  		 $('#s_msg').text('正在提交留言...').show();

	              		 return true;

              		},
              	success:function(data){
              		  if (data[0])
              		  {
              		  	/*document.cookie=data[2];*/
              		  	add_comment(data[1]);
            		  	$('#s_msg').text('留言提交成功！');
              		  	$('#comment').val('');
						return false;
              		  }
              		  else
              		  {  if (data[1]==-102)
              		  	 showinfo('计算错误，请仔细算一下！');
              		  	 $('#s_msg').text('留言提交失败！');
              		  	 $('#checkret').focus();
						 return false;
              		  }
              		}
              });

</script>
